<template>
  <j-modal
    :title="title"
    :width="600"
    :visible="visible"
    :maskClosable="false"
    :fullscreen="false"
    @ok="handleOk"
    @cancel="handleCancel"
    :destroyOnClose="true"
    cancelText="关闭"
  >
    <a-form-model>
      <a-row :gutter="24">
        <a-col :span="24">
          <a-form-item label="文件编号" :labelCol="labelCol" :wrapperCol="wrapperCol">
            <a-input placeholder="请输入文件编号" v-model="model.docNo"></a-input>
          </a-form-item>
        </a-col>
        <a-col :span="24">
          <a-form-item label="附件下载截止日期"  :labelCol="labelCol" :wrapperCol="wrapperCol">
            <j-date
                placeholder="请选择附件下载截止时间"
                :showTime="true"
                v-model="model.downloadEndTime"
                dateFormat="YYYY-MM-DD HH:mm:ss"
              />
          </a-form-item>
        </a-col>
        <a-col :span="24">
          <a-form-item label="附件"  :labelCol="labelCol" :wrapperCol="wrapperCol">
            <j-upload v-model="model.downloadAttachment"></j-upload>
          </a-form-item>
        </a-col>
      </a-row>
    </a-form-model>
    <template slot="footer"> 
      <a-button @click="handleCancel">取消</a-button>
      <a-button @click="handleOk" type="primary">提交</a-button>
    </template>
  </j-modal>
</template>

<script>
import { httpAction, getAction } from '@/api/manage'
import Add from '@/views/exTenderFile/Add'
import { DatePicker as ADatePicker } from 'ant-design-vue'

export default {
  name: 'AddModal',
  components: {
    ADatePicker,
    Add
  },
  data () {
    return {
      title: '招标文件-编辑',
      visible: false,
      disableSubmit: false,
      model: {
        downloadAttachment: null,
        docNo: null
      },
      url: {
        updateDoc: '/exTenderFileClariModi/exTenderFileClariModi/updateDoc'
      },
      detailInfo:{},
       labelCol: {
          xs: { span: 24 },
          sm: { span: 6 },
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 16 },
        },
    }
  },
  watch: {},
  created () {},
  computed: {},
  methods: {
    showModal (info) {
      console.log(info)
      this.model = { id:info.id,docNo:info.docNo,downloadEndTime:info.downloadEndTime,downloadAttachment:info.downloadAttachment }
      this.visible = true
    },
    close () {
      this.$emit('close')
      this.visible = false
      this.disableSubmit = false
    },
    handleOk () {
      const that = this
      // 触发表单验证
      that.confirmLoading = true
      let httpurl = this.url.updateDoc
      let method = 'post'
      httpAction(httpurl, this.model, method)
        .then((res) => {
          if (res.success) {
            that.$message.success('编辑成功')
          } else {
            that.$message.warning(res.message)
          }
          that.$emit('refresh')
        })
        .finally(() => {
          that.confirmLoading = false
          that.close()
        })
    },
    handleCancel () {
      this.close()
    }
  }
}
</script>
